#region

using System.Web;

#endregion

namespace HouseHoldBudget.Core
{
    /// <summary>
    ///   Represents a common helper
    /// </summary>
    public interface IWebHelper
    {
        #region Instance Properties

        /// <summary>
        ///   Gets or sets a value that indicates whether the client is being redirected to a new location using POST
        /// </summary>
        bool IsPostBeingDone { get; set; }

        /// <summary>
        ///   Gets a value that indicates whether the client is being redirected to a new location
        /// </summary>
        bool IsRequestBeingRedirected { get; }

        #endregion

        #region Instance Methods

        /// <summary>
        ///   Get context IP address
        /// </summary>
        /// <returns> URL referrer </returns>
        string GetCurrentIpAddress();

        /// <summary>
        ///   Gets store host location
        /// </summary>
        /// <param name="useSsl"> Use SSL </param>
        /// <returns> Store host location </returns>
        string GetStoreHost(bool useSsl);

        /// <summary>
        ///   Gets store location
        /// </summary>
        /// <returns> Store location </returns>
        string GetStoreLocation();

        /// <summary>
        ///   Gets store location
        /// </summary>
        /// <param name="useSsl"> Use SSL </param>
        /// <returns> Store location </returns>
        string GetStoreLocation(bool useSsl);

        /// <summary>
        ///   Gets this page name
        /// </summary>
        /// <param name="includeQueryString"> Value indicating whether to include query strings </param>
        /// <returns> Page name </returns>
        string GetThisPageUrl(bool includeQueryString);

        /// <summary>
        ///   Gets this page name
        /// </summary>
        /// <param name="includeQueryString"> Value indicating whether to include query strings </param>
        /// <param name="useSsl"> Value indicating whether to get SSL protected page </param>
        /// <returns> Page name </returns>
        string GetThisPageUrl(bool includeQueryString, bool useSsl);

        /// <summary>
        ///   Get URL referrer
        /// </summary>
        /// <returns> URL referrer </returns>
        string GetUrlReferrer();

        /// <summary>
        ///   Gets a value indicating whether current connection is secured
        /// </summary>
        /// <returns> true - secured, false - not secured </returns>
        bool IsCurrentConnectionSecured();

        /// <summary>
        ///   Get a value indicating whether the request is made by search engine (web crawler)
        /// </summary>
        /// <param name="context"> HTTP context </param>
        /// <returns> Result </returns>
        bool IsSearchEngine(HttpContextBase context);

        ///<summary>
        ///  Returns true if the requested resource is one of the typical resources that needn't be processed by the cms engine.
        ///</summary>
        ///<param name="request"> HTTP Request </param>
        ///<returns> True if the request targets a static resource file. </returns>
        ///<remarks>
        ///  These are the file extensions considered to be static resources: .css .gif .png .jpg .jpeg .js .axd .ashx
        ///</remarks>
        bool IsStaticResource(HttpRequest request);

        /// <summary>
        ///   Maps a virtual path to a physical disk path.
        /// </summary>
        /// <param name="path"> The path to map. E.g. "~/bin" </param>
        /// <returns> The physical path. E.g. "c:\inetpub\wwwroot\bin" </returns>
        string MapPath(string path);


        /// <summary>
        ///   Modifies query string
        /// </summary>
        /// <param name="url"> Url to modify </param>
        /// <param name="queryStringModification"> Query string modification </param>
        /// <param name="anchor"> Anchor </param>
        /// <returns> New url </returns>
        string ModifyQueryString(string url, string queryStringModification, string anchor);

        /// <summary>
        ///   Gets query string value by name
        /// </summary>
        /// <typeparam name="T"> </typeparam>
        /// <param name="name"> Parameter name </param>
        /// <returns> Query string value </returns>
        T QueryString<T>(string name);

        /// <summary>
        ///   Remove query string from url
        /// </summary>
        /// <param name="url"> Url to modify </param>
        /// <param name="queryString"> Query string to remove </param>
        /// <returns> New url </returns>
        string RemoveQueryString(string url, string queryString);

        /// <summary>
        ///   Restart application domain
        /// </summary>
        /// <param name="makeRedirect"> A value indicating whether </param>
        /// <param name="redirectUrl"> Redirect URL; empty string if you want to redirect to the current page URL </param>
        void RestartAppDomain(bool makeRedirect = false, string redirectUrl = "");

        /// <summary>
        ///   Gets server variable by name
        /// </summary>
        /// <param name="name"> Name </param>
        /// <returns> Server variable </returns>
        string ServerVariables(string name);

        /// <summary>
        ///   Gets a value indicating whether connection should be secured
        /// </summary>
        /// <returns> Result </returns>
        bool SslEnabled();

        #endregion
    }
}